User avatar test

jamesperet 9 years ago
parent
commit
b260f4943a

+ 3 - 3
app/views/devise/registrations/edit.html.erb

@@ -13,13 +13,13 @@
13 13
 				    
14 14
 	    			   <div class="fileupload fileupload-new pull-right" data-provides="fileupload" style="margin-top: 5px;">
15 15
 	    					<div class="fileupload-preview thumbnail" data-trigger="fileinput" style="width: 140px; height: 140px;">
16
-							<%=  image_tag resource.avatar.to_s if resource.avatar? %>
16
+							<%=  image_tag @user.avatar.to_s if @user.avatar? %>
17 17
 						</div>
18 18
 						<br>
19 19
 	    					<span class="btn btn-default btn-file btn-mini" style="width: 135px;">
20 20
 	    						<span class="fileinput-new"></span>
21 21
 	    						<span class="fileinput-exists"></span>
22
-	    						<%= f.file_field :image, class: 'hidden', label: (t 'blog.select_image') %>
22
+	    						<%= f.file_field :avatar, class: 'hidden', label: (t 'blog.select_image') %>
23 23
 	    					</span>
24 24
 	    			    </div>
25 25
 				    
@@ -36,7 +36,7 @@
36 36
 			    		        <%= f.password_field :password_confirmation, label: (t 'registration.password_confirmation'), required: false, class: 'input-block-level' %>
37 37
 			    		    <% end %>
38 38
 			    		    <%= f.form_group :slug, class: "pull-left", style: 'margin-left: 27px; width: 30%;' do %>
39
-			    		        <%= f.password_field :current_password, label: (t 'registration.current_password'), required: true, class: 'input-block-level' %>
39
+			    		        <%= f.password_field :current_password, label: (t 'registration.current_password'), required: false, class: 'input-block-level' %>
40 40
 			    		    <% end %>
41 41
 			         </div>
42 42
 				    

+ 13 - 0
features/step_definitions/helper_steps.rb

@@ -39,4 +39,17 @@ end
39 39
 
40 40
 When /^I visit the homepage$/ do
41 41
  visit ""
42
+end
43
+
44
+# File Upload
45
+
46
+Then(/^I upload the file "(.*?)" to the field "(.*?)"$/) do |arg1, arg2|
47
+  @test_file_path = File.expand_path(('../../spec/fixtures/' + arg1), File.dirname(__FILE__))
48
+  attach_file arg2, @test_file_path 
49
+end
50
+
51
+# Check for image
52
+
53
+Then(/^I should see the image "(.*?)"$/) do |image_name|
54
+  page.should have_selector("img[src$='#{image_name}']")
42 55
 end

+ 13 - 3
features/user_account.feature

@@ -72,8 +72,7 @@ Feature: User Account
72 72
 		And I click in the button "Update"
73 73
 		Then I should see "You updated your account successfully"
74 74
 		Then I should see "Donald Duck"
75
-	
76
-	@focus	
75
+		
77 76
 	Scenario: Change user password
78 77
 		Given the user "Monty" "Cantsin" with email "monty_cantsin@canada.com" and password "12345678" exists
79 78
 		And I go to the login page
@@ -88,4 +87,15 @@ Feature: User Account
88 87
 		And I click in the link "Logout"
89 88
 		And I go to the login page
90 89
 		And I log in with the email "monty_cantsin@canada.com" and password "87654321"
91
-		Then I should see "Signed in successfully"
90
+		Then I should see "Signed in successfully"
91
+	
92
+	@focus	
93
+	Scenario: Change User Avatar
94
+		Given the user "Monty" "Cantsin" with email "monty_cantsin@canada.com" and password "12345678" exists
95
+		And I go to the login page
96
+		And I log in with the email "monty_cantsin@canada.com" and password "12345678"
97
+		And I click in the link "Account"
98
+		When I upload the file "avatar.jpg" to the field "user_avatar"
99
+		And I click in the button "Update"
100
+		And I click in the link "Account"
101
+		Then I should see the image "avatar.jpg"

BIN
spec/fixtures/avatar.jpg